package art.yulang.demo.controller;

import art.yulang.demo.service.IDemoService;
import art.yulang.framework.annotations.YuAutowired;
import art.yulang.framework.annotations.YuController;
import art.yulang.framework.annotations.YuRequestMapping;
import art.yulang.framework.annotations.YuSecurity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@YuController
@YuRequestMapping("/demo")
public class DemoController {
    @YuAutowired
    private IDemoService demoService;

    @YuRequestMapping("/query")
    @YuSecurity(value = {"yulang", "zhangsan"})
    public String queryName(HttpServletRequest request, HttpServletResponse response, String name){
        System.out.println("DemoController中的name：" + name);
        return demoService.get(name);
    }

    @YuRequestMapping("/add")
    @YuSecurity(value = {"lisi"})
    public String add(HttpServletRequest request, HttpServletResponse response, String name){
        System.out.println("DemoController中的name：" + name);
        return "add success";
    }

    @YuRequestMapping("/delete")
    @YuSecurity(value = {"wangwu"})
    public String delete(HttpServletRequest request, HttpServletResponse response, String name){
        System.out.println("DemoController中的name：" + name);
        return "delete success";
    }
}
